package Thread;

import java.util.concurrent.locks.ReentrantLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: LianBao
 * Date: 2024-08-10
 * Time: 16:49
 */
public class demo32 {
    public static void main(String[] args) {

        ReentrantReadWriteLock outerReadLock = new ReentrantReadWriteLock();//先创建外部类

        //读锁
        ReentrantReadWriteLock.ReadLock readLock = outerReadLock.readLock();//通过外部类来创建内部类
        readLock.lock();
        readLock.unlock();

        //写锁
        ReentrantReadWriteLock.WriteLock writeLock = outerReadLock.writeLock();//通过外部类来创建内部类
        writeLock.lock();
        writeLock.unlock();
    }
}
